document.querySelector('#btn-register').addEventListener('click', async () =>{
    const form =document.querySelector('.register-form')
    const data = serialize(form,{empty:true,hash:true})
    const {username,password} = data
    if(username.trim() ==='' || password.trim() ==='')return showToast('用户名或密码不能为空')
        try {
            const res = await axios.post('/register',data)
            console.log('注册',res)
            if(res.data.code === 10000){
                showToast('注册成功')
                setTimeout(() => {
                    location.href = './login.html'
                }, 800)
            }else{
                showToast(res.message)
            }
        } catch (error) {
            showToast('注册失败')
        }
})
   

